package org.edu.controller;

import javax.annotation.Resource;

import org.apache.struts2.ServletActionContext;
import org.edu.bean.Illegalreg;
import org.edu.common.PageView;
import org.edu.common.QueryResult;
import org.edu.service.IllegalregService;

import com.opensymphony.xwork2.ActionSupport;
@SuppressWarnings("serial")
public class IllegalregController extends ActionSupport {
	private Integer page = 1;
	private Illegalreg entity;
	@Resource
	private IllegalregService illegalregservice;
	

	public Illegalreg getEntity() {
		return entity;
	}


	public void setEntity(Illegalreg entity) {
		this.entity = entity;
	}


	public IllegalregService getIllegalregservice() {
		return illegalregservice;
	}


	public void setIllegalregservice(IllegalregService illegalregservice) {
		this.illegalregservice = illegalregservice;
	}


	public Integer getPage() {
		return page;
	}


	public void setPage(Integer page) {
		this.page = page;
	}


	@Override
	public String execute() throws Exception {
		try {
			
		//	illegalregservice.save(entity);
		} catch (Exception e) {
			e.printStackTrace();
		}		
		return "success";
	}
	public String input() throws Exception {
		try{
			illegalregservice.save(entity);
		}catch(Exception e){
			e.printStackTrace();
		}
		PageView< Illegalreg> pageView = new PageView<Illegalreg>(20,page);
		QueryResult<Illegalreg> result = illegalregservice.getQueryResult(pageView.getFirstResult(),pageView.getMaxresult());
		pageView.setQueryResult(result);
		ServletActionContext.getRequest().setAttribute("pageView",pageView);
		return "success";
	}

	public String list() throws Exception{
	
			PageView< Illegalreg> pageView = new PageView<Illegalreg>(20,page);
			QueryResult<Illegalreg> result = illegalregservice.getQueryResult(pageView.getFirstResult(),pageView.getMaxresult());
			pageView.setQueryResult(result);
			ServletActionContext.getRequest().setAttribute("pageView",pageView);
			return SUCCESS;
		}
	
}
